---
feature_name: Array Methods (ECMAScript 2015)
chrome_version: 45
feature_id: 6732923508097024
---
<p><a target="_blank" href="http://www.ecma-international.org/ecma-262/6.0">ECMAScript 2015 specification</a> adds additional static methods on <code>Array</code> and instance
methods on <code>Array.prototype</code>.</p>

<h2>Array.from ( items [ , mapfn [ , thisArg ] ] ) <a target="_blank" href="http://www.ecma-international.org/ecma-262/6.0/#sec-array.from">#</a></h2>
<p>
The <code>Array.from()</code> method converts an array-like object to a true
array. It takes an optional second parameter, which can be used to execute a map
function on each element of the array that is being created.
</p>

{% include js_snippet.html filename='demo1.js' title='' %}

<p>
It comes in handy when dealing with the infamous <code>NodeList</code>
returned by <code>document.querySelectorAll</code>.
</p>

{% include js_snippet.html filename='demo2.js' title='' %}

<h2>Array.of ( ...items ) <a target="_blank" href="http://www.ecma-international.org/ecma-262/6.0/#sec-array.of">#</a></h2>
<p>
The <code>Array.of()</code> method creates a new <code>Array</code> instance
with any number of arguments, regardless of their type.
</p>

{% include js_snippet.html filename='demo3.js' title='' %}

<h2>Array.prototype.copyWithin (target, start [ , end ] ) <a target="_blank" href="http://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.copywithin">#</a></h2>
<p>
The <code>copyWithin()</code> method copies the sequence of array elements
within the array to the position starting at <code>target</code>. The copy is
taken from the index positions of the second and third arguments
<code>start</code> and <code>end</code>. The <code>end</code> argument is
optional and defaults to the length of the array.
</p>

{% include js_snippet.html filename='demo4.js' title='' %}

<p>If <code>start</code> is negative, it will be treated as <code>length+start</code> where <code>length</code> is the length of the array. If <code>end</code> is negative, it will be treated as <code>length+end</code>.

{% include js_snippet.html filename='demo5.js' title='' %}

<h2>Array.prototype.fill (value [ , start [ , end ] ] ) <a target="_blank" href="http://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.fill">#</a></h2>
<p>
The <code>fill()</code> method fills all the elements of an array between an
optional <code>start</code> index and an optional <code>end</code> index with a
static <code>value</code>.
The <code>start</code> argument defaults to 0. The <code>end</code>
argument defaults to the length of the array.
</p>

{% include js_snippet.html filename='demo6.js' title='' %}

<h2>Array.prototype.find ( predicate [ , thisArg ] ) <a target="_blank" href="http://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.find">#</a></h2>
<p>
The <code>find()</code> method returns a value in the array, if at least one
element in the array satisfies the provided <code>predicate</code> function. If
not, <code> undefined</code> is returned. <code>find()</code> does not mutate
the array on which it is called.
</p>

{% include js_snippet.html filename='demo7.js' title='' %}

<h2>Array.prototype.findIndex ( predicate [ , thisArg ] ) <a target="_blank" href="http://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.findindex">#</a></h2>
<p>
The <code>findIndex()</code> method returns an index in the array, if at least
one element in the array satisfies the provided <code>predicate</code>
function. If not, -1 is returned. <code>findIndex()</code> does not mutate the
array on which it is called.
</p>

{% include js_snippet.html filename='demo8.js' title='' %}
